package qmlgui

import (
    //"path/filepath"
    "github.com/therecipe/qt/core"
    "github.com/therecipe/qt/qml"
)


//type UISignal struct {
//    core.QObject
//    _ func()        `signal:"reloading"`
//}

var ui *UIBridge

type UIBridge struct {
    core.QObject

    _ func()    `constructor:"init"`
    _ func()    `slot:"ClearCache"`
    Engine      *qml.QQmlApplicationEngine
} 


func (ui *UIBridge) init() {
    ui.ConnectClearCache(Clear)
}


func (ui *UIBridge) LoadEngine(e *qml.QQmlApplicationEngine) {
    ui.Engine = e
}


func Clear() {
    ui.Engine.ClearComponentCache()
}


//func NewUIBridge(e *qml.QQmlApplicationEngine) *UIBridge {
//    ui := &UIBridge {
//        engine: e,
//        reloading: NewUISignal(nil),
//    }
//
//    return ui
//}

//func (ui *UIBridge) init(e *qml.QQmlApplicationEngine) {
//    ui.engine = e
//    ui.Reloading = NewUISignal(nil)
//}
//
//func (ui *UIBridge) Reload(d string) {
//    //ui.Reloading.Reloading()
//    //ui.engine.ClearComponentCache()
//    p := filepath.Join(d, "MainWindow.qml")
//    ui.engine.Load(core.NewQUrl3(p, 0))
//}
